import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

// 2. 引入组件样式
import 'vant/lib/index.css'

// 引入flexable
import 'amfe-flexible/index.js'

// global css
import '@/styles/index.scss'

// 全局组件通信
import emitter from 'tiny-emitter/instance'

// 权限
import './permission'
import { Swipe, SwipeItem } from 'vant'

const app = createApp(App)

// 组件通信
app.config.globalProperties.$emitter = emitter

// 为了可以根据相对路径跳转
app.config.globalProperties.append = (path, pathToAppend) =>
  path + (path.endsWith('/') ? '' : '/') + pathToAppend

// 全局异常
app.config.errorHandler = (err) => {
  setTimeout(() => {
    console.error('====>', err)
  }, 50)
}

app.use(Swipe)
  .use(SwipeItem)
  .use(store)
  .use(router)
  .mount('#app')
